using System.Collections.Generic;
using System.IO;
namespace cssp
{
	public enum BlockType { Import, Symbol, Target }

	public class CodeBlock
	{
		public BlockType Type;
		public int StartLineNum, EndLineNum;
		public string Name;

		public CodeBlock(BlockType type)
		{
			Type = type;
		}
	}

	/// <summary>
	/// A symbol declaration.
	/// </summary>
	public class Symbol : CodeBlock
	{
		public string Value;

		public Symbol()
			: base(BlockType.Target)
		{
		}
	}


	public class Unit
	{
		string mFilename;
		string mText;
		List<CodeBlock> mImports;
		List<Symbol> mSymbols;
		List<Token> mSymbolReferences;
		Dictionary<string, List<CodeBlock>> mTargets;
		bool mHasErrors;

		#region Properties

		public string Filename
		{
			get { return mFilename; }
		}

		public string Text
		{
			get { return mText; }
			internal set { mText = value; }
		}

		public List<CodeBlock> Imports
		{
			get { return mImports; }
		}

		public List<Symbol> Symbols
		{
			get { return mSymbols; }
		}

		public List<Token> SymbolReferences
		{
			get { return mSymbolReferences; }
		}

		public Dictionary<string, List<CodeBlock>> Targets
		{
			get { return mTargets; }
		}

		public bool HasErrors
		{
			get { return mHasErrors; }
			set { mHasErrors = value; }
		}

		#endregion

		public Unit(string filename)
		{
			mFilename = Path.GetFullPath(filename);
			mImports = new List<CodeBlock>();
			mSymbols = new List<Symbol>();
			mSymbolReferences = new List<Token>();
			mTargets = new Dictionary<string, List<CodeBlock>>();
			mHasErrors = false;
		}
	}
}
